package AcWing.每日一题2025;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ZhuYi
 * @create 2025/3/13 18:31
 */
public class 蛋糕游戏_6118 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());

        while (t-- != 0) {
            int n = Integer.parseInt(br.readLine());
            int l = n / 2 + 1;
            Long a = Long.MAX_VALUE;
            String[] split = br.readLine().split(" ");
            Long[] sum = new Long[n + 1];
            sum[0] = 0L;
            for (int i = 1; i <= n; i++) {
                Long x = Long.parseLong(split[i - 1]);
                sum[i] = sum[i - 1] + x;
                if (i >= l) a = Math.min(a, sum[i] - sum[i - l]);

            }
            System.out.println(a + " " + (sum[n] - a));
        }
    }
}
